< previous page page_325 next page >

Page 325
If you make dt too large in this routine, the points you connect on the curve are far apart and the curve does not appear smooth. If you make dt smaller, the curve appears smoother. If you make dt too small, you waste a lot of time finding points on the curve that you do not need. When the points you calculate are drawn at the nearest pixels, many of the points will end up at the same position. You could have used fewer points to get the same result.
Figure 11.1 shows a circle drawn three times with this method. To create the picture on the left, dt was set to p/4. This value is not small enough, so the circle does not appear smooth. In the middle picture, dt is p/8. This makes the circle smoother, but straight edges are still visible. The value of dt in the right picture is p/16. This circle appears reasonably smooth. Making dt smaller than p/16 makes the routine take longer without producing great improvements in the result.
Example program Circle1 uses this method to draw circles like those shown in Figure 11.1. Enter minimum and maximum values for t and the value of dt. Then when you click on the Go button, the program draws the corresponding circle.
The following code shows the parametric functions X(t) and Y(t) that program Circle1 uses to draw circles. The value Radius was chosen to make the circle fill the picture box.
e10a6a0a59f035e870d90cca05b85fce.gif
' The parametric function X(t).
Private Function X(ByVal t As Single) As Single
    X = Radius * Cos(t)
End Function

' The parametric function Y(t).
Private Function Y(ByVal t As Single) As Single
    Y = Radius * Sin(t)
End Function
DrawCurve
Program Circle1 uses the DrawCurve subroutine shown earlier to draw circles. The functions X(t) and Y(t) return the points on the circle for different values of t.
z0345-01.gif
Figure 11.1
Circle drawn with dt= 
p/4, p/8, and p/16.

 
< previous page page_325 next page >